package com.koron.device.controller;

import com.koron.bean.base.Response;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.device.bean.po.EquipmentMaintainPo;
import com.koron.device.service.EquipmentMaintainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "设备维护")
@RestController
@RequestMapping("/equipment/maintain")
public class EquipmentMaintainController {

    @Autowired
    private EquipmentMaintainService equipmentMaintainService;


    public String getCurrDs(){
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "保存设备维护信息")
    @PostMapping("/save")
    public Response save(@RequestBody EquipmentMaintainPo equipmentMaintainPo){
        return ADOConnection.runTask(getCurrDs(), equipmentMaintainService, "save", Response.class, equipmentMaintainPo);
    }


    @ApiOperation(value = "修改设备维护信息")
    @PostMapping("/update")
    public Response update(@RequestBody EquipmentMaintainPo equipmentMaintainPo){
        return ADOConnection.runTask(getCurrDs(), equipmentMaintainService, "update", Response.class, equipmentMaintainPo);
    }


    @ApiOperation(value = "删除设备维护信息")
    @GetMapping("/delete")
    public Response delete(@RequestParam String id){
        return ADOConnection.runTask(getCurrDs(), equipmentMaintainService, "delete", Response.class, id);
    }


    @ApiOperation(value = "根据id查找设备维护信息")
    @GetMapping("/selectOne")
    public Response get(@RequestParam String id){
        return ADOConnection.runTask(getCurrDs(), equipmentMaintainService, "findById", Response.class, id);
    }

}
